﻿import std.core;
import user;
import strings;
import mem;

void test_user_types();
void test_user_singleton();
void test_user_dbg();
void test_string_encoding();
void test_mem_read();

int main()
{
    std::cout << "cpplibv1\n";
    test_user_types();
    test_string_encoding();
    test_mem_read();
    test_user_singleton();
    test_user_dbg();
}

void test_user_types() {
    uint64 a = 0xFF;
    std::cout << a << std::endl;
}

class MySingleton : public Singleton<MySingleton> {
    friend class Singleton<MySingleton>;
    MySingleton() = default;
public:
    void show() {
        printf("addr = %p\n", this);
    }
};
void test_user_singleton() {
    MySingleton::get()->show();
    MySingleton::get()->show();
}

void test_user_dbg() {
    dbgprint("%s %d", "abc", 111);
}

void test_string_encoding() {
    auto a = "中";
    auto b = atou8(a);
    std::cout << " a: " << a << " b: " << b << std::endl;
}

void test_mem_read() {
    uint64 a = 10;
    auto result = r8((uint64) &a);
    std::cout << "r8 result = " << result << std::endl;
}
